<template>
  <div id="DangerousAppraisal">
    <div class="top">
      <!--{{row.NODE_GUID}}-->
      <img v-if="row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}' || row.NODE_GUID==='{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}'" style="margin: 0 auto" class="imgtop"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/fgx2.png" />
      <img v-else style="margin: 0 auto" class="imgtop"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/fgx.png" />
      <p>
        <span style="width: 125px;display: inline-block;text-align: left">危房鉴定</span>
        <span style="width: 150px;display: inline-block;text-align: right">复核鉴定</span>
      </p>
    </div>
    <div class="content">
      <van-form validate-first :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
        <div class="inputWrap">
          <van-field readonly v-model="row.SQR" placeholder="请输入户主姓名" label="户主姓名"
            :rules="[{ required: true, message: '请填写户主姓名' }]" />
        </div>
        <div class="inputWrap">
          <van-field readonly v-model="row.ZJH" label="身份证号码" name="validator" @blur.native.capture="handleGetCityData"
            placeholder="身份证号码" :rules="[{ validator, message: '请输入正确身份证号码' }]" />
        </div>
        <div class="inputWrap">
          <van-field readonly placeholder="请输入手机号码" v-model="row.SJH" label="手机号" :rules="[
            { required: true, message: '请填写您的手机号码！' },
            { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' }
          ]" name="pattern" />
        </div>
        <div class="inputWrap">
          <van-field readonly clickable name="picker" :value="formData.SCITY | inUseName1(CityColumns)" label="所属市"
            placeholder="请选择所属市" :rules="[{ required: true, message: '请选择所属市' }]" />
        </div>
        <div class="inputWrap">
          <van-field readonly clickable name="picker" :value="formData.XCITY | inUseName1(XianColumns)" label="所属县(区)"
            placeholder="请选择所属县(区)" />
        </div>
        <div class="inputWrap">
          <van-field readonly clickable name="picker" :value="formData.ZCITY | inUseName1(TownColumns)" label="所属镇"
            placeholder="请选择所属镇" />
        </div>
        <div class="inputWrap">
          <van-field readonly clickable name="picker" v-if="CCITYNAME" :value="CCITYNAME" label="所属村"
            placeholder="请选择所属村" />
          <van-field readonly clickable name="picker" v-else :value="formData.CCITY | inUseName1(CunColumns)" label="所属村"
                     placeholder="请选择所属村" />
        </div>
        <div class="inputWrap">
          <van-field readonly v-model="formData.FWDZ" label="房屋地址" placeholder="请输入房屋地址" />
        </div>
        <div class="inputWrap">
          <van-field readonly v-model="formData.CS" label="建筑层数" placeholder="请输入建筑层数" />
        </div>
        <div class="inputWrap">
          <van-field readonly v-model="formData.NF" label="建造年份" placeholder="请输入建造年份" />
        </div>
        <div class="inputWrap">
          <van-field readonly v-model="formData.JDJG" label="鉴定机构" placeholder="请输入鉴定机构" />
        </div>
      </van-form>
      <p class="subTitle">
        <span class="line"></span>鉴定信息
      </p>
      <van-form validate-first :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
        <!-- <div class="inputWrap">
          <van-field v-model="formData.houseapplicant" placeholder="请输入鉴定报告" label="鉴定报告" />
        </div>-->
        <div class="inputWrap">
          <span style="color: #FF0000;">*</span>
          <van-field clickable readonly :value="formData.JDLX | inUseName(ENUM.JDLXARR)" label="鉴定类型"
            placeholder="请选择鉴定类型" @click="ENUM.JDLX = true" />
          <van-popup v-model="ENUM.JDLX" position="bottom" get-container="#popup">
            <van-picker show-toolbar :columns="ENUM.JDLXARR" value-key="DICNAME" @confirm="confirmJDLX"
              @cancel="ENUM.JDLX = false" />
          </van-popup>
        </div>
        <div class="inputWrap">
          <span style="color: #FF0000;">*</span>
          <van-field v-model="formData.JDBGBH" label="鉴定报告编号" placeholder="请输入鉴定报告编号" />
        </div>
        <div class="inputWrap">
          <span style="color: #FF0000;">*</span>
          <van-field clickable readonly :value="formData.JDDJ | inUseName(ENUM.JDDJARR)" label="鉴定等级"
            placeholder="请选择鉴定等级" @click="ENUM.JDDJ = true" />
          <van-popup v-model="ENUM.JDDJ" position="bottom" get-container="#popup">
            <van-picker show-toolbar :columns="ENUM.JDDJARR" value-key="DICNAME" @confirm="confirmJDDJ"
              @cancel="ENUM.JDDJ = false" />
          </van-popup>
        </div>
        <div class="inputWrap">
          <span style="color: #FF0000;">*</span>
          <van-field readonly clickable name="datetimePicker" v-model="formData.JDSJ" label="鉴定时间"
            placeholder="请选择鉴定时间" />
        </div>
        <div class="inputWrap">
          <span style="color: #FF0000;">*</span>
          <van-field label="上传人" v-model="formData.SCR" placeholder="请输入上传人" />
        </div>
        <p class="title">备注</p>
        <div class="inputWrap">
          <van-field v-model="formData.BZ" autosize type="textarea" placeholder="请输入备注" label />
        </div>
      </van-form>
      <CheckeRgister ref="CheckeRgister" :row="row" />
      <JDJGPDF :row="row" :rowDataNew="rowDataNew" ref="JDJGPDF" />
      <!--<div v-for="(item,index) in file" :key="index">-->
      <!--<p class="title">-->
      <!--<span style="color: #FF0000;">*</span>-->
      <!--{{item.name}}-->
      <!--</p1>-->
      <!--<van-uploader @click-upload="getList(item)" @click-preview="lookFile" :after-read="afterRead" :before-delete="delectFile" v-model="item.fileList" accept=".jpg,.gif,.png,.jpeg,.txt,.pdf,.doc,.docx,.xls,.xlsx" multiple />-->
      <!--</div>-->
    </div>
    <div class="footer">
      <van-button @click="PreviewReport" type="info">预览鉴定报告</van-button>
      <van-button @click="saveData" type="info">保存</van-button>
      <van-button @click="getinsertDataView('提交')" type="info">提交</van-button>

      <!--<div class="bottomBtn" style="margin-bottom:10px" @click="saveData">保存</div>-->
      <!--<div class="bottomBtn" @click="getinsertDataView('提交')">提交</div>-->
      <!--<div class="bottomBtn">预览鉴定报告</div>-->
    </div>
  </div>
</template>

<script>
import { QuerySignCallback, dataServerOpenDataView, GetFileData, FileServerUpload, DelectFile, getNum, dataTransFilePreview, FileServerProxy } from '@/utils/api'
import JDJGPDF from "@/components/ZLJ/JDJGPDF" //鉴定公司基本信息
import CheckeRgister from "./CheckeRgister" //农村房屋结构安全排查登记表
export default {
  name: 'DangerousAppraisal',
  data() {
    return {
      CCITYNAME:'',
      showEdition: false,
      row: {},
      rowDataNew:{},
      rowGuid: '',
      dataguid: '9788c08d-3d96-4f0d-85da-d233094abcf6',
      formData: {
        CS: '',
        NF: '',
        SCITY: '',
        XCITY: '',
        ZCITY: '',
        CCITY: '',
        JDLX: '',
        JDDJ: '',
        JDSJ: '',
        BZ: '',
        JDBGBH: '',
        OPTYPE: 1,
        SCR: '',
        FWDZ: '',
        JDJG:'',
        // DJJC_QT:'',
        // FWCD_QT:''
      },
      currentDate: new Date(),
      CityColumns: [],
      XianColumns: [],
      TownColumns: [],
      CunColumns: [],
      showPickerq: false,
      isAdd: true,
      ENUM: {
        JDLXARR: [],
        JDLX: false,
        JDDJARR: [],
        JDDJ: false
      },
      file: [
        {
          name: '鉴定报告',
          groupGuid: '88d711ba-870c-40f2-a81d-71df8caeefd4',
          fileList: []
        },
        {
          name: '房屋照片',
          groupGuid: '8188d4d5-0898-44b9-b7f9-4f84dfb58f11',
          fileList: []
        }
      ],
      file2: [
        {
          name: '鉴定报告',
          groupGuid: '88d711ba-870c-40f2-a81d-71df8caeefd4',
          fileList: []
        },
        {
          name: '房屋照片改造前',
          groupGuid: 'd46b2463-896b-4fff-9ad1-48ae7cbc7c9c',
          fileList: []
        },
        {
          name: '房屋照片改造后',
          groupGuid: 'c96cca59-db53-4626-b608-9fa007b37e8a',
          fileList: []
        }
      ]
    }
  },
  components: {
    JDJGPDF,
    CheckeRgister
  },
  watch: {},
  filters: {
    inUseName: function (msg, data) {
      let name = ''
      data.forEach(item => {
        if (item.DICID == msg) {
          name = item.DICNAME
        }
      })
      return name
    },
    inUseName1: function (msg, data) {
      let name = ''
      data.forEach(item => {
        if (item.CITYCODE == msg) {
          name = item.CITYNAME
        }
      })
      return name
    }
  },
  methods: {
    validator(val) {
      var idcardReg =
        /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
      return idcardReg.test(val)
    },
    createBG() {
      //   this.getinsertDataView()
      //   this.$router.push({
      //         path: '/JDJGPDF',
      //         query:{
      //           data:this.row.ROW_GUID
      //         }
      //       })
    },
    getCityOpenDataView: async function () {
      this.CityColumns = []
      let dataGuid = 'e9c98787-4966-4365-80b0-c1cc678c6f85'
      let token = window.localStorage.getItem('token')
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: dataGuid,
          searchObject: JSON.stringify([]),
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CityColumns = JSON.parse(res.data.data).Data
    },
    getXianOpenDataView: async function (data) {
      this.XianColumns = []
      let dataGuid = '77fdf2b0-0eb5-4243-a0a4-6185299ccd34'
      let searchObject = JSON.stringify([{ field: 'pid', value: data, operator: '=' }])
      let token = window.localStorage.getItem('token')
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      debugger
      this.XianColumns = JSON.parse(res.data.data).Data
    },
    getTownOpenDataView: async function (data) {
      this.TownColumns = []
      let dataGuid = '24d07248-ba49-4b82-9029-b5eccaff179d'
      let searchObject = JSON.stringify([{ field: 'pid', value: data, operator: '=' }])
      let token = window.localStorage.getItem('token')
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      debugger
      this.TownColumns = JSON.parse(res.data.data).Data
    },
    getCunOpenDataView: async function (data) {
      this.CunColumns = []
      let dataGuid = 'd3aaed7c-84ee-4de3-b70e-07fe188cdc8e'
      let searchObject = JSON.stringify([{ field: 'pid', value: data, operator: '=' }])
      let token = window.localStorage.getItem('token')
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CunColumns = JSON.parse(res.data.data).Data
    },
    getEnum: async function (viewID) {
      let token = window.localStorage.getItem('token')
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: viewID,
          searchObject: JSON.stringify([]),
        },
      };
      const res = await QuerySignCallback(params);
      switch (viewID) {
        case 'b15c9597-ccb8-435c-b43d-06fe30fc0e08':
          this.ENUM.JDLXARR = JSON.parse(res.data.data).Data
          break
        case 'c7007467-d12c-4b87-948e-aa58b2df2131':
          this.ENUM.JDDJARR = JSON.parse(res.data.data).Data
          break
        default:
          break
      }
    },
    getList(item) {
      this.groupGuids = item.groupGuid
    },
    //
    confirmJDLX(val) {
      this.formData.JDLX = val.DICID
      this.ENUM.JDLX = false
    },
    confirmJDDJ(val) {
      this.formData.JDDJ = val.DICID
      this.ENUM.JDDJ = false
    },
    //获取相关材料
    getFile: async function () {
      let groupGuid = []
      this.file.forEach(item => {
        groupGuid.push(item.groupGuid)
      })
      const res1 = await GetFileData({
        groupGuid: groupGuid.join(','),
        toRowGuid: this.rowGuid
      })
      if (res1.data.FilesInfo.length > 0) {
        res1.data.FilesInfo.forEach(element => {
          this.file.forEach(item => {
            if (element.GROUPGUID == item.groupGuid) {
              element['isImage'] = item.name == '鉴定报告' ? false : true
              element['file'] = {
                name: element.FILENAME
              }
              this.getFileUrl(element, item);
              // element['url'] =
              //   window.g.BaseURL +
              //   'FileServer/api/Preview?token=' +
              //   window.localStorage.getItem('token') +
              //   '&' +
              //   'fileGuid=' +
              //   encodeURIComponent(element.ROW_GUID)
              // item.fileList.push(element)
            }
          })
        })
      }
    },
    //相关材料
    afterRead(file) {
      // 此时可以自行将文件上传至服务器
      this.getFileServerUpload(file.file)
    },
    delectFile: async function (file) {
      let fileguid = "";
      if (file.ROW_GUID) {
        fileguid = file.ROW_GUID;
      } else {
        fileguid = this.fileGuid;
      }
      if (fileguid) {
        let params = {
          accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: {
            fileGuid: fileguid,
            token: window.localStorage.getItem("token"),
          },
        };
        const res = await FileServerProxy(params);
        let data = JSON.parse(res.data.data).Success;
        if (data) {
          this.$toast.success("删除成功!");
        }
      }
    },
    // delectFile: async function (file) {
    //   if (file.ROW_GUID) {
    //     const res = await DelectFile({
    //       fileGuid: file.ROW_GUID,
    //       token: window.localStorage.getItem('token')
    //     })
    //     if (res.data.Success) {
    //       this.$toast.success('成功!')
    //     } else {
    //       this.$toast.fail(res.data.Msg)
    //     }
    //   }
    // },
    getFileServerUpload: async function (file) {
      let formData = new FormData()
      // if (file instanceof Array) {
      //   file.forEach(item => {
      //     formData.append('file', item.file)
      //   })
      // } else {
      //   formData.append('file', file.file)
      // }
      let _this = this;
      formData.append('file', file)
      formData.append('toRowGuid', this.rowGuid)
      formData.append('groupGuid', this.groupGuids)
      formData.append('token', window.localStorage.getItem('token'))
      const res = await FileServerUpload(formData)
      if (res.data.Success == true) {
        this.$toast.success('上传成功!')
        if (this.groupGuids == "88d711ba-870c-40f2-a81d-71df8caeefd4") {
          res.data.FileList.forEach((item, index) => {
            item['isImage'] = false
            item['file'] = {
              name: item.FILENAME
            }
            item['url'] =
              window.g.BaseURL +
              'FileServer/api/Preview?token=' +
              window.localStorage.getItem('token') +
              '&' +
              'fileGuid=' +
              encodeURIComponent(item.FILEGUID)
            _this.file[0].fileList[_this.file[0].fileList.length - 1 - index] = item
            _this.$forceUpdate()
          })
        }
        // this.$notify({ type: 'success', message: '上传成功!' });        // this.$notify({ type: 'success', message: '上传成功!' });
      }
    },
    //获取附件文件流
    getFileUrl: async function (element, item) {
      let formData = new FormData();
      formData.append("accessCode", "98bcf528966e48ce896a8b3fd02d45d5");
      formData.append(
        "cityCode",
        window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000"
      );
      formData.append(
        "paramStr",
        JSON.stringify({
          fileGuid: element.ROW_GUID,
        })
      );
      let response = await dataTransFilePreview(formData);
      if (response) {
        var img = new Blob([new Int8Array(response.data, 0)], {
          type: response.headers["content-type"],
        }); //type类型可自定义
        element["isImage"] = true;
        element["url"] = window.URL.createObjectURL(img);
        item.fileList.push(element);
      }
    },
    //
    lookFile(item) {
      if (itme.isImage == false) {
        // if (ZWJSBridge) {
        ZWJSBridge.openLink({
          "url": item.url
        }).then(res => {
        }).catch(err => {
          window.open(item.url)
        })
        // }
      }
    },
    getinsertDataView: async function (data) {
      if(this.formData.JDDJ&&this.formData.JDBGBH&&this.formData.JDLX&&this.formData.JDSJ&&this.formData.SCR){
        this.saveData("2")
      this.row.JDDJ = this.formData.JDDJ
      setTimeout(()=>{
          this.$router.push({
        path: '/TreeSelectAutoSend',
        query: { data: this.row, list: true }
      })
      },1000)
      } else{
        this.$toast.fail("请填写必填字段")
      }
      // let me = this
      // let add = true
      // this.$refs.JDJGPDF.save()
      // if (me.row.NODE_GUID == '{E3402372-B41D-4B99-9463-27A385E5C212}') {
      //   me.formData.OPTYPE = 2
      // }
      // if (add) {
      //   if (me.formData.JDLX && me.formData.JDDJ && me.formData.JDSJ && me.formData.JDBGBH && me.formData.SCR) {
      //     let accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
      //     if (!me.formData.ROW_GUID) {
      //       accessCode = '0fb3f6123d1b4fe6851c99532c463f6f'
      //       me.formData['ROW_GUID'] = me.rowGuid
      //       me.formData['TO_ROW_GUID'] = me.row.ROW_GUID
      //     }
      //     let params = {
      //       dataGuid: me.dataguid,
      //       strParams: JSON.stringify([me.formData]),
      //       token: window.localStorage.getItem('token')
      //     }
      //     let params1 = {
      //       accessCode: accessCode,
      //       appKey: '6738b790-69e8-11ec-a673-6805cab640a0',
      //       cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
      //       params: params
      //     }
      //     const res = await QuerySignCallback(params1)
      //     if (eval('(' + res.data.data + ')').Success == true) {
      //       //me.$toast.success('成功！')
      //       me.row.JDDJ = this.formData.JDDJ
      //       if (data){
      //         this.$router.push({
      //           path: '/TreeSelectAutoSend',
      //           query: { data: this.row, list: true }
      //         })
      //       }
      //
      //     } else {
      //       me.$toast.fail(res.data.msg)
      //     }
      //   }
      //   else {
      //     me.$toast.success('请输入必填项！')
      //   }
      // }
    },
    saveData: async function (data1) {
      this.$refs.JDJGPDF.save('1')
      debugger
      let data = this.formData
      let obj2 = this.$refs.CheckeRgister.formData
      console.log(this.$refs.CheckeRgister.formData)
      Object.assign(data, obj2);
      let accessCode = ''
      let dataGuid = "9788c08d-3d96-4f0d-85da-d233094abcf6"
      if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}' || this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}') {
        dataGuid = "81454c15-9443-443d-a7ab-f6ed4c23f46d"
        data.OPTYPE = 2
      } else {
        dataGuid = "9788c08d-3d96-4f0d-85da-d233094abcf6"
        if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}') {
          data.OPTYPE = 2
        } else {
          data.OPTYPE = 1
        }

      }
      console.log(this.row,'jjj')
      data.TO_ROW_GUID = this.row.ROW_GUID
      data.F_JDJG = this.formData.JDJG
      // alert(this.isAdd)
      if (this.isAdd) {
        //获取子组件生成的新的rowGuid
        accessCode = '0fb3f6123d1b4fe6851c99532c463f6f'
        console.log(this.$refs.JDJGPDF.rowGuid)
        data.ROW_GUID = this.$refs.JDJGPDF.rowGuid
      } else {
        data.ID = this.ID
        accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
      }
      let params = {
        dataGuid: dataGuid,
        strParams: JSON.stringify([data]),
        token: window.localStorage.getItem('token')
      }
      let params1 = {
        accessCode: accessCode,

        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: params
      }
      const res = await QuerySignCallback(params1)
      debugger
      if(data1!= "1"){
        if (eval('(' + res.data.data + ')').Success == true) {
        this.$toast.success('成功！')
        this.getData()
      } else {
        this.$toast.fail('失败！')
      }
      }
    },
    getData: async function () {
      var  optype="";
      let dataGuid = "9788c08d-3d96-4f0d-85da-d233094abcf6"
      if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}'|| this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}') {
        dataGuid = "81454c15-9443-443d-a7ab-f6ed4c23f46d"
      } else {
        dataGuid = "9788c08d-3d96-4f0d-85da-d233094abcf6"
      }
       if (this.row.NODE_GUID == "{E3402372-B41D-4B99-9463-27A385E5C212}") {
          optype= 2
        } else {
          optype = 1
        }
      let params = {
        dataguid: dataGuid,
        searchObject: JSON.stringify([{ field: 'to_row_guid', value: this.row.ROW_GUID, link: 'OR', operator: '=' }]),
      }
      let params1 = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: params
      }
      const res = await QuerySignCallback(params1)
      let data = eval('(' + res.data.data + ')').Data
      if(this.row.WF_GUID!=='{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}'){
        this.rowDataNew = data[0]
      }
      if(dataGuid == "9788c08d-3d96-4f0d-85da-d233094abcf6"&&this.row.WF_GUID=='{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}'){
        //镇街督办
        if(data.length > 0 ){
          this.rowDataNew = data[0]
        } else{
          this.rowDataNew = JSON.parse(JSON.stringify(this.row))
          this.rowDataNew.ROW_GUID = ""
          console.log(this.rowDataNew,'jklklklkl')
        }
      } else if(dataGuid == "81454c15-9443-443d-a7ab-f6ed4c23f46d"&&this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}'){
        if(data.length > 0 ){
          this.rowDataNew = data[0]
        } else{
          this.rowDataNew = JSON.parse(JSON.stringify(this.row))
          this.rowDataNew.ROW_GUID = ""
          console.log(this.rowDataNew,'jklklklkl')
        }
      }
      if (data.length > 0) {
        this.ID = data[0].ID
        this.isAdd = false
        for (let i in this.formData) {
          if (data[0][i]) {
            if (i=='JDSJ') {
              this.formData[i] = data[0][i].split(" ")[0]
            }else{
              this.formData[i] = data[0][i]
            }
          }
        }
        // this.formData = data[0]
        this.formData['JDJG'] = this.row.JDJG
        if (data[0].SCR) {
          this.formData.SCR = data[0].SCR
        }
        this.rowGuid = this.formData.ROW_GUID
      } else {
        this.isAdd = true
        for (let i in this.formData){
          if (this.row[i]){
            if (i=='FWDZ' || i=='CS'|| i=='NF'|| i=='JDJG'|| i=='SCITY'|| i=='XCITY'|| i=='ZCITY'|| i=='CCITY'){
              this.formData[i] = this.row[i]
            }
          }
        }
        this.rowGuid = this.newGuid()
      }
      // if(String(this.formData.JDSJ).length>9){
      //   this.formData.JDSJ = String(this.formData.JDSJ).substring(0,String(this.formData.JDSJ).length -8)
      // }
      //   this.getFile()
    },
    PreviewReport() {
      let groupGuid = "", dataGuid = ""
      if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}') {
        groupGuid = "{AE32F4B0-ED78-4C30-B894-F52A5ABA912B}"
        dataGuid = "005d990a-3c77-46b3-9e6a-6ec5ed33b24c"
      } else {
        groupGuid = "{4CD6F0FC-AC91-430B-B838-70DBABE0F603}"
        dataGuid = "005d990a-3c77-46b3-9e6a-6ec5ed33b24c"
      }
      if(this.row.WF_GUID == '{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}'){
        dataGuid = "57a43986-96ca-4da0-a44e-7e4610927bce"
      }
      let baseurl = this.row.URL.replace(/#/g,":")
      let url = baseurl + 'PrintServer/api/PreviewWordRpt?groupGuid=' + (groupGuid) + '&toRowGuid=' + this.row.ROW_GUID + '&dataGuid=' + dataGuid
      let url1 = window.g.BaseURL + '/api/farmerHouse/proxy/dataTransFile/v2?fileUrl='+encodeURIComponent(url)
      this.$router.push({
          path: "./viewPDF",
          query: {
            data:url1
          },
        });
    },
    getNumData: async function (data) {
      let numPrefix = ""
      if (data){
        numPrefix = data
      }else{
        let paer = {
          procName: "up_processusername",
          dtParams: JSON.stringify([
            { I_USERID: "'"+this.row.ROW_GUID+"'", I_TYPE:(this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}' || this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}')?31:28 },
          ]),
          token: window.localStorage.getItem("token"),
        };
        let procNamesk = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: paer,
        };
        const reskh = await FileServerProxy(procNamesk);
        debugger
        console.log(JSON.parse(reskh.data.data))
        if (JSON.parse(reskh.data.data).Data[0]){
          numPrefix = JSON.parse(reskh.data.data).Data[0].TYSHXYDM
          this.formData.JDJG = JSON.parse(reskh.data.data).Data[0].JDJG
        }
      }
      let params1 = {
        "accessCode": "b03be941dc27498ebcc46311330ee97d",
        cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
        "keyType": 2,
        "numPrefix": numPrefix
      }
      const res = await getNum(params1)
      this.formData.JDBGBH = res.data.data
    },
    getData1: async function(){
      let paer = {
        procName: "up_processusername",
        dtParams: JSON.stringify([
          { I_USERID: "'"+this.row.ROW_GUID+"'", I_TYPE:33 },
        ]),
        token: window.localStorage.getItem("token"),
      };
      this.getData()
      let procNamesk = {
        accessCode: "69db6bece3a7480592e2ec753d1e335e",
        cityCode: window.localStorage.getItem("citycode")
          ? window.localStorage.getItem("citycode")
          : "441300000000",
        params: paer,
      };
      const reskh = await FileServerProxy(procNamesk);
      let data = eval('(' + reskh.data.data + ')').Data
      for (let i in this.formData){
        if (data[0][i]){
          this.formData[i] = data[0][i]
        }
      }
      this.row.SQR = data[0].SQR
      this.CCITYNAME = data[0].CCITY
      this.getXianOpenDataView( data[0].SCITY)
      this.getTownOpenDataView( data[0].XCITY)
      this.getCunOpenDataView( data[0].ZCITY)
      // let paer1 = {
      //   procName: "up_processusername",
      //   dtParams: JSON.stringify([
      //     { I_USERID: "'"+this.row.ROW_GUID+"'", I_TYPE:32 },
      //   ]),
      //   token: window.localStorage.getItem("token"),
      // };
      // let procNamesk1 = {
      //   accessCode: "69db6bece3a7480592e2ec753d1e335e",
      //   cityCode: window.localStorage.getItem("citycode")
      //     ? window.localStorage.getItem("citycode")
      //     : "441300000000",
      //   params: paer1,
      // };
      // const reskh1 = await FileServerProxy(procNamesk1);
      // let data1 = eval('(' + reskh1.data.data + ')').Data
      // debugger
      // // for (let i in this.formData){
      // //   if (data1[0][i]){
      // //     this.formData[i] = data1[0][i]
      // //   }
      // // }
      // console.log(data1)
    }
  },
  mounted() {
    this.row = JSON.parse(this.$route.query.data)
    // this.saveData('1')
    console.log(this.row)
    if (this.row.WF_GUID=='{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}') {
      this.getData1()
    }else{
      this.getXianOpenDataView(this.row.SCITY)
      this.getTownOpenDataView(this.row.XCITY)
      this.getCunOpenDataView(this.row.ZCITY)
      this.getData()
    }
    // //获取当前时间
    //  var date = new Date()
    //  var year = date.getFullYear() //获取当前年份
    //  var mon = date.getMonth() + 1 //获取当前月份
    //  var da = date.getDate() //获取当前日
    //  var d = document.getElementById('Date')
    //  var time1 = year + '-' + mon + '-' + da
    this.formData.JDSJ = this.getDate(true)
    if (this.row.NODE_GUID == '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}') {
      // this.file[1] = {
      //   name: "房屋照片改造前",
      //   groupGuid: "d46b2463-896b-4fff-9ad1-48ae7cbc7c9c",
      //   fileList: [],
      // }
      // this.file.push({
      //   name: "房屋照片改造后",
      //   groupGuid: "c96cca59-db53-4626-b608-9fa007b37e8a",
      //   fileList: [],
      // })
      this.file = this.file2
      this.dataguid = '81454c15-9443-443d-a7ab-f6ed4c23f46d'
      this.formData.OPTYPE = 2
    }
    this.showEdition = this.$store.state.Edition
    this.getEnum('b15c9597-ccb8-435c-b43d-06fe30fc0e08')
    this.getEnum('c7007467-d12c-4b87-948e-aa58b2df2131')

    this.getCityOpenDataView()

    if (this.showEdition) {
      $('#DangerousAppraisal .van-field__control').css('fontSize', '16px !important')
      $('#DangerousAppraisal .van-cell').css('fontSize', '16px !important')
    } else {
      $('#DangerousAppraisal .van-field__control').css('fontSize', '20px !important')
      $('#DangerousAppraisal .van-cell').css('fontSize', '20px !important')
    }
    this.getNumData(this.row.TYSHXYDM)
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '鉴定公司'
      })
        .then(res => {
        })
        .catch(err => {
        })
    }
  }
}
</script>
<style scoped lang="scss">
#DangerousAppraisal {
  height: 100vh;

  .top {
    height: 80px;
    background: #ffffff;
    padding-top: 25px;
    text-align: center;

    .imgtop {
      width: 60%;
      margin: 0 auto;
    }

    .origin {
      width: 22px;
      height: 22px;
      background: #007aff;
      border-radius: 50%;
      display: inline-block;
    }
  }

  .content {
    width: 100%;
    height: calc(100% - 140px);
    overflow: auto;
    background: #ffffff;
    padding: 10px;

    .subTitle {
      color: #3f8ffc;
      height: 40px;
      line-height: 40px;
      font-size: 16px;
      //   .line {
      //     width: 6px;
      //     height: 26px;
      //     background: #3f8ffc;
      //     display: inline-block;
      //     margin-right: 10px;
      //   }
    }

    .title {
      color: black;
      font-size: 16px;
      line-height: 40px;
    }

    .inputWrap {
      display: flex;
      justify-content: center;
      align-items: center;
      border-bottom: 1px solid #d2d2d2;
    }

    .van-cell {
      padding: 10px 0;
    }
  }

  .footer {
    padding: 10px;
    text-align: center;

    .bottomBtn {
      min-width: 20%;
      height: 40px;
      background: #007aff;
      line-height: 40px;
      text-align: center;
      color: #ffffff;
      font-weight: bold;
      float: left;
      margin-right: 10px;
      padding: 0 10px;
    }
  }
}
</style>
<style lang="scss">
#DangerousAppraisal {
  .van-field__label {
    width: auto !important;
  }

  .mediumFontSize {
    .van-field__label {
      font-size: 20px;
    }
  }

  .el-input__inner {
    /*font-size: 16px;*/
    text-align: right;
    border: none;
  }

  .van-cell:not(:last-child)::after {
    left: 0;
    // border-bottom: 1px solid rgb(210, 210, 210);
  }

  .van-cell::after {
    border-bottom: none;
  }

  .van-cell {
    padding: 10px 0;
    font-size: 16px;
  }

  .van-field__control {
    text-align: right;
  }

  textarea {
    text-align: left !important;
  }

  .van-field__label {
    color: black !important;
    letter-spacing: 1px;
  }

  .van-cell {
    color: black;
  }
}
</style>
